﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace TuongLai_Schools
{
    public class cls_DM_Chucvudoanthe
    {
        public DataTable GetAll_Chucvudoanthe()
        {
            DbAccess db = new DbAccess();
            db.CreateNewSqlCommand_Text();
            DataTable dataTable = db.ExecuteDataTable("Select ChucVuDoanTheID,TenChucVuDoanThe,GhiChu,isChangeable from DM_ChucVuDoanThe");
            return dataTable;
        }
        public bool Insert(clsDM_Chucvudoanthe obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuDoanTheID", obj.ChucVuDoanTheID);
                db.AddParameter("@TenChucVuDoanThe", obj.TenChucVuDoanThe);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("insert into DM_ChucVuDoanThe(TenChucVuDoanThe,GhiChu,isChangeable) values(N'" + obj.TenChucVuDoanThe + "',N'" + obj.GhiChu + "','" + obj.isChangeable + "')");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool update(clsDM_Chucvudoanthe obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuDoanTheID", obj.ChucVuDoanTheID);
                db.AddParameter("@TenChucVuDoanThe", obj.TenChucVuDoanThe);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("update DM_ChucVuDoanThe set TenChucVuDoanThe=N'" + obj.TenChucVuDoanThe + "',GhiChu=N'" + obj.GhiChu + "',isChangeable='" + obj.isChangeable + "' where ChucVuDoanTheID='" + obj.ChucVuDoanTheID + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool delete(int Chucvudoantheid)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuDoanTheID", Chucvudoantheid);
                db.ExecuteNonQuery("delete DM_ChucVuDoanThe where ChucVuDoanTheID='" + Chucvudoantheid + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
